import { PlayState } from '@store/reducers/player.reducer';
import { createSelector, createFeatureSelector } from '@ngrx/store';

export const featureKey = 'player';
export const selectPlayerState = (state: PlayState) => state;

export const getPlayer = createFeatureSelector<PlayState>(featureKey);
// export const getPlaying = createSelector(selectPlayerState, (state: PlayState) => state.playing);
export const getPlayList = createSelector(selectPlayerState, (state: PlayState) => state.playList);
export const getSongList = createSelector(selectPlayerState, (state: PlayState) => state.songList);
export const getPlayMode = createSelector(selectPlayerState, (state: PlayState) => state.playMode);
export const getCurrentIndex = createSelector(selectPlayerState, (state: PlayState) => state.currentIndex);
export const getCurrentSong = createSelector(selectPlayerState, ({ playList, currentIndex }: PlayState) => playList[currentIndex]);
export const getCurrentAction = createSelector(selectPlayerState, (state: PlayState) => state.currentAction);
